import type { DynamicProps } from '/#/utils';
import type { BasicTableProps, BasicColumn } from '/@/components/Table/src/types/table';
import { FormProps } from '/@/components/Table';
import { FormSchema } from '/@/components/Form';
import { getstanddrive } from '/@/api/sys/gateway/gateway';
type Props = Partial<DynamicProps<BasicTableProps>>;
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
// 列配置
const tableColumns: BasicColumn[] = [
  {
    title: '驱动编号',
    dataIndex: 'id',
    width: 60,
  },
  {
    title: '品牌',
    dataIndex: 'fit_brand',
    width: 60,
    customRender: ({ record }) => {
      return h(
        'div',
        record.fit_brand.map((item) => {
          return h(Tag, { color: '#FF7875', style: { marginRight: '3px' } }, () => item);
        }),
      );
    },
  },
  {
    title: '型号',
    dataIndex: 'fit_device_type',
    width: 60,
    customRender: ({ record }) => {
      return h(
        'div',
        record.fit_device_type.map((item) => {
          return h(Tag, { color: '#FF7875', style: { marginRight: '3px' } }, () => item);
        }),
      );
    },
  },
  {
    title: '驱动名称',
    dataIndex: 'name',
    width: 130,
  },
  {
    title: '自带属性数量',
    dataIndex: 'attr_count',
    width: 100,
  },
  {
    title: '驱动版本',
    dataIndex: 'version',
    width: 100,
  },
  {
    title: '驱动类型',
    dataIndex: 'connect_type',
    width: 100,
  },
  {
    title: '创建时间',
    dataIndex: 'create_time',
    width: 100,
  },
  {
    title: '驱动更新时间',
    dataIndex: 'update_time',
    width: 100,
  },
];
const searchSchemas: FormSchema[] = [
  {
    field: 'drive_name',
    component: 'Input',
    label: '驱动名称',
    labelWidth: 80,
    componentProps: {
      placeholder: '',
    },
    colProps: {
      span: 6,
    },
  },
];
export const formConfig: Partial<FormProps> = {
  labelWidth: 100,
  schemas: searchSchemas,
  actionColOptions: {
    span: 4,
    style: { textAlign: 'left', marginLeft: '20px' },
  },
};
export const tableConfig: Props = {
  api: getstanddrive,
  columns: tableColumns,
  useSearchForm: true,
  formConfig: formConfig,
  clickToRowSelect: false,
  showTableSetting: false,
  showIndexColumn: false,
  rowKey: 'id',
  bordered: true,
  fetchSetting: {
    listField: 'list',
    totalField: 'total',
    sizeField: 'page_size',
  },
  actionColumn: {
    width: 80,
    title: '操作',
    slots: { customRender: 'action' },
  },
};
